home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 13 / AMIGAplus Sonderheft 13 (1998)(ICP)(DE)[!].iso / rexx / organizewindows.bed < prev    next >
Text File  |  1997-12-03  |  3KB  |  168 lines

  1. /*
  2. ** $VER: OrganizeWindows.bed 1.0 (02.01.96)
  3. **
  4. ** Organizes all the windows on the screen as follows:
  5. **
  6. ** STACK
  7. ** Puts the windows in horizontal slices, stacked vertically on the
  8. ** screen
  9. **
  10. ** CASCADE
  11. ** Puts the windows in a cascade, one top of the other. All title bars
  12. ** then become visible.
  13. **
  14. ** TILE
  15. ** Puts all windows in a 2D tile pattern.
  16. **
  17. ** ICONIFY
  18. ** Iconifies all windows, and aligns them on the left side of the screen.
  19. **
  20. ** Modified by Marco Negri
  21. */
  22.  
  23.  
  24. OPTIONS RESULTS
  25. OPTIONS FAILAT 11
  26. PARSE ARG style
  27.  
  28. IF style ~= "" THEN DO
  29.     style = UPPER(style)
  30.  
  31.     GetScreenInfo
  32.     PARSE VAR RESULT . . screenwidth screenheight . . . '"'screenname'"'
  33.  
  34.     GetDocuments
  35.     docs = RESULT
  36.  
  37.     GetPort
  38.     originalport = RESULT
  39.  
  40.     numicons = 0
  41.     iconheight = 0
  42.     n=0
  43.  
  44.     DO WHILE docs ~= ""
  45.         PARSE VAR docs '"'names.n'"' ports.n docs
  46.         ADDRESS VALUE ports.n
  47.  
  48.         icons.n = FALSE
  49.  
  50.         GetWindowInfo
  51.         IF WORD(RESULT,1) = "ON" THEN DO
  52.             icons.n = TRUE;
  53.             numicons = numicons + 1
  54.             iconheight = WORD(RESULT,5)
  55.         END
  56.  
  57.         n = n+1
  58.     END
  59.  
  60.     availheight = (screenheight - (numicons * iconheight))
  61.     numfull = n - numicons
  62.  
  63.     IF numfull = 0 THEN DO
  64.         style = 'ICONIFY'
  65.     END
  66.  
  67.     IF style = 'STACK' THEN DO
  68.         h = availheight % numfull
  69.         w = 0
  70.         y=0
  71.  
  72.         DO i=0 TO n-1
  73.             IF icons.i = FALSE THEN DO
  74.                 w = w + 1
  75.                 IF (w = numfull) THEN DO
  76.                     h = h + (availheight // numfull)
  77.                 END
  78.  
  79.                 ADDRESS VALUE ports.i
  80.                 MoveSizeWindow 0 y screenwidth h
  81.                 Window2Front
  82.                 y = y + h
  83.             END
  84.         END
  85.     END
  86.  
  87.     IF style = 'CASCADE' THEN DO
  88.         h = availheight
  89.         y = 0
  90.  
  91.         IF iconheight = 0 THEN iconheight = 15
  92.  
  93.         DO i=0 TO n-1
  94.             ADDRESS VALUE ports.i
  95.             IF icons.i = FALSE THEN DO
  96.                 MoveSizeWindow 0 y screenwidth h
  97.                 Window2Front
  98.                 h = h - iconheight
  99.                 y = y + iconheight
  100.             END
  101.         END
  102.     END
  103.  
  104.     IF style = 'ICONIFY' THEN DO
  105.         y = 0
  106.         DO i=0 TO n-1
  107.             ADDRESS VALUE ports.i
  108.             IconifyWindow ON
  109.             GetWindowInfo
  110.             h = WORD(RESULT,5)
  111.             y = y + h + 1
  112.             MoveSizeWindow 0 y
  113.         END
  114.     END
  115.  
  116.     IF style = 'TILE' THEN DO
  117.         DO i=2 TO 100
  118.             IF i*i > numfull THEN LEAVE
  119.         END
  120.  
  121.         i = i-1
  122.         numw = i
  123.         numh = i
  124.         extras = numfull - (i*i)
  125.  
  126.         IF extras > numh THEN DO
  127.             numh = numh + 1
  128.             extras = extras - numw
  129.         END
  130.  
  131.         extras = - (numh - extras)
  132.  
  133.         win = 0
  134.         wininrow = numw + (extras >= 0)
  135.         wwidth = screenwidth % wininrow
  136.         wheight = availheight % numh
  137.         x = 0
  138.         y = 0
  139.         row = 0
  140.  
  141.         DO i=0 TO n-1
  142.             IF icons.i = FALSE THEN DO
  143.                 win = win + 1
  144.                 row = row + 1
  145.  
  146.                 ADDRESS VALUE ports.i
  147.  
  148.                 IF row // wininrow = 0 THEN DO
  149.                     MoveSizeWindow x y (screenwidth - x) wheight
  150.                     x = 0
  151.                     y = y + wheight
  152.                     extras = extras + 1
  153.                     wininrow = numw + (extras >= 0)
  154.                     wwidth = screenwidth % wininrow
  155.                     row = 0
  156.  
  157.                     IF win + wininrow = numfull THEN wheight = availheight - y
  158.                 END; ELSE DO
  159.                     MoveSizeWindow x y wwidth wheight
  160.                     x = x + wwidth
  161.                 END
  162.  
  163.                 Window2Front
  164.             END
  165.         END
  166.     END
  167. END
  168.